package com.tx.admin.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

import com.tx.admin.core.entity.TreeEntity;
import com.tx.admin.core.service.TreeService;
import com.tx.admin.core.po.PagePo;
import com.tx.admin.core.repository.TreeRepository;

public abstract class TreeServiceImpl <E extends TreeEntity<E>> extends SuperServiceImpl<E> implements TreeService<E> {

	@Autowired
	private TreeRepository<E> treeRepository;
	

	public List<E> findByParentId(String parentId) {
		// TODO Auto-generated method stub
		return treeRepository.findByParentId(parentId);
	}

	@Override
	public Page<E> pageBuildChildren(PagePo<E> params) {
		// TODO Auto-generated method stub
		return treeRepository.pageBuildChildren(params);
	}



	@Override
	public E findByIdBuildParent(String id) {
		return this.treeRepository.findByIdBuildParent(id);
	}

	@Override
	public E findByIdBuildChildren(String id) {
		// TODO Auto-generated method stub
		E parent = this.findById(id);
		List<E> children = this.treeRepository.buildChildren(parent);
		parent.setChildren(children);
		return parent;
	}


	
}
